/* UEMessage.h */

#ifndef UE_MESSAGE_H
#define UE_MESSAGE_H

#pragma pack(push, 1)

#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */

/* UE Request Type Definition */
#define   UE_REQ_TYPE_STOP               1               /* stop service */
#define   UE_REQ_TYPE_STATUS             2               /* query service status */
#define   UE_REQ_TYPE_AUTH               3               /* authentication */
#define   UE_REQ_TYPE_ACTION             4               /* take action */
#define   UE_REQ_TYPE_UPDATE             5               /* update */

/* UE Response Status Definition */
#define   UE_RES_STATUS_SUCCESS          0               /* success */
#define   UE_RES_STATUS_INVALID_REQUEST  1               /* failed */
#define   UE_RES_STATUS_FAILED          99               /* generic failed */

/* UE Action Type Definition */
#define   UE_ACTION_TYPE_MOUSE_CLICK     1               /* mouse click */

typedef struct 
{
	int               version;                           /* request message version */
	int               request_type;                      /* request type */
	int               identifer;                         /* identifer of the client send this request, usually be the client process ID. */
	int               addr;                              /* IP address of the client that initialize the original request */
	int               port;                              /* port of the client that initialize the original request */
	unsigned int      sequence;                          /* client specified sequence number of this request */
	unsigned int      len;                               /* length of the request type related data */
} ue_request_header;

typedef struct
{
	int               status;                            /* result of the request, 0 indicate success, otherwise some error occur */
	int               identifer;                         /* identifer of the client send this request, usually be the client process ID. */
	int               addr;                              /* IP address of the client that initialize the original request */
	int               port;                              /* port of the client that initialize the original request */
	unsigned int      sequence;                          /* client specified sequence number of this request */
	unsigned int      len;                               /* length of the response type related data */
} ue_response_header;

typedef struct
{
	int               type;                              /* action type */
	int               ueid;                              /* client ueid */
	int               x;                                 /* X value of the target point */
	int               y;                                 /* Y value of the target point */
} ue_action_data;

#pragma warning (disable:4200)
typedef struct
{
	int               left;                              /* X value of start point of the update image data */
	int               top;                               /* Y value of start point of the update image data */
	int               width;                             /* width of the update image data */
	int               height;                            /* height of the update image data */
	int               len;                               /* image data len */
	char              data[];                            /* image data */
} ue_update_item;

typedef struct
{
	int               ueid;                              /* lastest ueid */
	int               width;                             /* screen width */
	int               height;                            /* screen height */
	int               count;                             /* update item number */
	ue_update_item   *items;                             /* update item array */
} ue_update_data;

#ifdef __cplusplus
}
#endif /* __cplusplus */

#pragma pack(pop)

#endif /* UE_MESSAGE_H */
